import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login'

Vue.use(VueRouter)

const AddClaims = () => import('../components/sales/claimsManage/AddClaims.vue')
const ClaimsList = () => import('../components/sales/claimsManage/ClaimsList.vue')
const AnminClaimsList = () => import('../components/admins/claimsManage/anminClaimsList.vue')

const routes = [
    //  ----------- 胡耀航----------
    {
        path: '/',
        name: 'Login',
        component: Login
    },
    {
        path: '/system',
        name: 'system',
        component: () => import('../views/system/System.vue'),
        children: [
            //  ----------- 严晴开始----------
            //  销售员操作页面的客户列表
            {
                path: 'customersList',
                name: 'Customers',
                component: () => import('../components/sales/customersManage/CustomersList.vue')
            },
            //  销售员操作页面的新增客户
            {
                path: 'addCustomers',
                name: 'AddCustomers',
                component: () => import('../components/sales/customersManage/addCustomers.vue')
            },
            //  修改客户页面
            {
                path: 'modifyCustomers/:_id',
                name: 'ModifyCustomers',
                component: () => import('../components/sales/customersManage/modifyCustomers.vue')
            },
            //  管理员界面的客户列表
            {
                path: 'adminCustomersList',
                name: 'AdminCustomers',
                component: () => import('../components/admins/customersManage/CustomersList.vue')
            },
            //  ----------- 严晴结束----------
            // ----------鲁甜甜------开始------
            // 平台管理员界面的查看销售员列表
            {
                path: 'salesList',
                name: 'SalesList',
                component: () => import('../components/admins/salesManage/SalesList.vue')
            },
            // 平台管理员界面的新增销售员
            {
                path: 'salesAdd',
                name: 'SalesAdd',
                component: () => import('../components/admins/salesManage/SalesAdd.vue')
            },
            // 平台管理员界面的修改销售员
            {
                path: 'salesUpdate/:_id',
                name: 'SalesUpdate',
                props: true,
                component: () => import('../components/admins/salesManage/SalesUpdate.vue')
            },
            // 平台管理员界面的查看该销售员负责的客户列表
            {
                path: 'aLLCustomersBelongToTheSales/:_id',
                name: 'ALLCustomersBelongToTheSales',
                props: true,
                component: () => import('../components/admins/salesManage/ALLCustomersBelongToTheSales.vue')
            },
            // 销售员界面的修改销售员的个人信息
            {
                path: 'salesChangeInformation',
                name: 'SalesChangeInformation',
                component: () => import('../components/sales/salesManage/SalesChangeInformation.vue')
            },
            // 销售员界面的修改销售员的密码
            {
                path: 'salesChangePassword',
                name: 'SalesChangePassword',
                component: () => import('../components/sales/salesManage/SalesChangePassword.vue')
            },
            // ----------鲁甜甜------结束-----
            //  ----------- 李媛媛----------
            {
                path: 'admins',
                name: 'Admins',
                component: () => import('../components/admins/adminsManage/Admin.vue')
            },
            {
                path: 'addAdmins',
                name: 'AddAdmins',
                component: () => import('../components/admins/adminsManage/AddAdmin.vue')
            },
            {
                path: 'updateAdmins/:_id',
                name: 'UpdateAdmins',
                // 当前路由的参数可以在组件中通过 props 来接收
                props: true,
                component: () => import('../components/admins/adminsManage/UpdateAdmin.vue')
            },
            //  ----------- 李媛媛----------
            {
                //胡凯扬
                path: 'classifysAdd',
                name: 'classifysAdd',
                props: true,
                //路由元信息  设置是否保存缓存  加条件判断某些缓存
                meta: {
                    keepAlive: true
                },
                component: () => import('../components/admins/classifysManage/classifysAdd.vue')
            },
            {
                //胡凯扬
                path: 'classifysList',
                name: 'classifysList',
                props: true,
                //路由元信息  设置是否保存缓存  加条件判断某些缓存
                meta: {
                    keepAlive: true
                },
                component: () => import('../components/admins/classifysManage/classifysList.vue')
            },
            {
                //胡凯扬
                path: 'classifysChange/:_id',
                name: 'classifysChange',
                props: true,
                //路由元信息  设置是否保存缓存  加条件判断某些缓存
                meta: {
                    keepAlive: true
                },
                component: () => import('../components/admins/classifysManage/classifysChange.vue')
            },
            //-----------何楠薪 start-----------
            //新增理赔
            {
                path: 'addClaims',
                name: 'AddClaims',
                component: AddClaims
            },
            //理赔列表
            {
                path: 'claimsList',
                name: 'ClaimsList',
                component: ClaimsList
            },
            //管理员操作理赔列表
            {
                path: 'anminClaimsList',
                name: 'AnminClaimsList',
                component: AnminClaimsList
            },
            {
                // 查款负责所有订单
                path: 'myAllOrdersList',
                component: () => import('../components/sales/ordersManage/OrdersList.vue')
            },
            {
                // 增加订单
                path: 'ordersAdd',
                component: () => import('../components/sales/ordersManage/OrdersAdd.vue')
            },
        
            // ---------罗钰坤-----------
            {
                // 查款负责所有订单
                path: 'myAllOrdersList',
                component: () => import('../components/sales/ordersManage/OrdersList.vue')
            },
            {
                // 增加订单
                path: 'ordersAdd',
                component: () => import('../components/sales/ordersManage/OrdersAdd.vue')
            },
            //蒲楷文开始
            {
                path: "addProducts",
                name: "AddProducts",
                component: () => import("../components/admins/productsManage/AddProducts")
            },
            {
                path: "productsList",
                name: "ProductsList",
                component: () => import("../components/admins/productsManage/ProductsList")
            },
            //蒲楷文结束
            // ---------罗钰坤-----------
            {
                // 查款负责所有订单
                path: 'myAllOrdersList',
                component: () => import('../components/sales/ordersManage/OrdersList.vue')
            },
            {
                // 增加订单
                path: 'ordersAdd',
                component: () => import('../components/sales/ordersManage/OrdersAdd.vue')
            },

            {
                // 管理员查看所有订单
                path: 'ordersList',
                component: () => import('../components/admins/ordersManage/OrdersList.vue')
            },
        ]
    }
]


const router = new VueRouter({
    routes
})
const token = localStorage.getItem('token')
// router.beforeEach((to,from,next)=>{
//   if(to.path.includes('system') ){
//     if(token == null){
//       alert('您还未登录');
//       next('/')
//     }else{
//       next()
//     }
//   }else{
//     next()
//   }
// })
export default router

